<!--业绩账号流水页面-->
<template>
  <el-card shadow="never" class="aui-card--fill">
    <div>
      <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
        <el-form-item prop="userId">
          <el-input v-model="dataForm.userId" type="text" placeholder="请输入用户ID" clearable></el-input>
        </el-form-item>
        <el-form-item prop="formId">
          <el-input v-model="dataForm.formId" type="text" placeholder="请输入业务编号" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-date-picker
              v-model="createDateList"
              type="daterange"
              placeholder="请选择创建日期"
              format="yyyy 年 MM 月 dd 日"
              range-separator="至"
              start-placeholder="开始创建日期"
              end-placeholder="结束创建日期"
              value-format="yyyy-MM-dd"
              class=""
              @change="createCK"
          />
        </el-form-item>
        <el-form-item>
          <el-button @click="getDataList()">查询</el-button>
        </el-form-item>
        <el-form-item v-if="$hasPermission('api:userAccountPerformance:export')">
          <el-button @click="exportHandle()" type="info">导出</el-button>
        </el-form-item>
                <el-form-item>
                  <el-button v-if="$hasPermission('api:userAccountPerformance:save')" type="primary"
                             @click="addOrUpdateHandle()">
                    新增
                  </el-button>
                </el-form-item>
                <el-form-item>
                  <el-button v-if="$hasPermission('api:userAccountPerformance:delete')" type="danger" @click="deleteHandle()">
                    删除
                  </el-button>
                </el-form-item>
      </el-form>
      <el-table v-loading="dataListLoading" :data="dataList" stripe highlight-current-row
                @selection-change="dataListSelectionChangeHandle" @sort-change="dataListSortChangeHandle"
                style="width: 100%;">
        <el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
        <el-table-column prop="userId" label="用户ID" header-align="center" align="center" width="" show-overflow-tooltip>
          <template slot-scope="{}" slot="header">
            <!-- 表头名称 -->
            <span>用户信息</span>
            <el-tooltip class="item" effect="dark" placement="top">
              <i class="el-icon-question" style="font-size:16px;"></i>
              <!-- 悬停提示内容 -->
              <div slot="content">
                <div>点击下方名称查看用户详细信息</div>
              </div>
            </el-tooltip>
          </template>
          <template slot-scope="{row}">
            <el-tag size="small" type="primary" style="cursor: pointer;" @click="showUserList(row.userDTO)" v-if="row.userDTO">{{row.userDTO.nickname}}</el-tag>
            <div v-if="!row.userDTO">{{row.userId}}</div>
          </template>
        </el-table-column>
        <el-table-column prop="formId" label="业务编号" header-align="center" align="center" width="" show-overflow-tooltip></el-table-column>
        <el-table-column prop="tradeNum" label="交易数量" header-align="center" align="center" width="" sortable show-overflow-tooltip></el-table-column>
        <el-table-column prop="tradeScene" label="场景" header-align="center" align="center" width="" show-overflow-tooltip>
          <template slot-scope="{row}">
            <div size="small" type="info">{{
                $getDictLabel("tradeScene", row.tradeScene)
              }}
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="tradeType" label="交易" header-align="center" align="center" width="" show-overflow-tooltip>
          <template slot-scope="{row}">
            <div>
              {{ $getDictLabel("tradeType", row.tradeType) }}
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="createDate" label="创建日期" header-align="center" align="center"></el-table-column>
      </el-table>
      <el-pagination :current-page="page" :page-sizes="[10, 20, 50, 100]" :page-size="limit" :total="total"
                     layout="total, sizes, prev, pager, next, jumper" @size-change="pageSizeChangeHandle"
                     @current-change="pageCurrentChangeHandle">
      </el-pagination>
      <!-- 弹窗, 新增 / 修改 -->
      <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
      <!--查看用户信息组件-->
      <com-user-list :visible.sync="showUser" :content="content"></com-user-list>
    </div>

  </el-card>
</template>

<script>
import mixinViewModule from '@/mixins/view-module'
import AddOrUpdate from './userAccountEdouAddOrUpdate.vue'
export default {
  mixins: [mixinViewModule],
  data() {
    return {
      mixinViewModuleOptions: {
        getDataListURL: '/api/userAccountPerformance/page',
        getDataListIsPage: true,
        deleteURL: '/api/userAccountPerformance',
        deleteIsBatch: true,
        exportURL: '/api/userAccountPerformance/exportUserAccountEdou'             // 导出接口，API地址
      },
      showUser:false,                   //是否显示用户信息
      content:{},                       //用户信息内容
      createDateList: [],               //创建时间数组
      dataForm: {
        id: '',                         //id
        tradeNum:'',                    //交易数量
        tradeScene: '',                 //场景：购物商城、积分商城、签到
        tradeType: '',                  //交易：增加、减少
        userId: '',                     //用户ID
        formId: '',                     //业务编号
        createDateStart: '',            //开始创建时间
        createDateEnd: '',              //结束创建时间
        nickname: '',                   //昵称
        mobile: '',                     //用户手机号
      },
    }
  },
  components: {
    AddOrUpdate
  },
  created() {

  },
  methods: {
    /*创建时间选择*/
    createCK() {
      if (!this.createDateList){
        this.dataForm.createDateStart = ''
        this.dataForm.createDateEnd = ''
        return
      }
      this.dataForm.createDateStart = this.createDateList[0]
      this.dataForm.createDateEnd = this.createDateList[1]
    },
    //显示用户信息
    showUserList(content){
      this.showUser=true;
      this.content= content;
    },
  }
}
</script>
